package com.itheima.controller;


import com.itheima.common.R;
import com.itheima.dto.ChangeUserDto;
import com.itheima.dto.EmpDto;
import com.itheima.dto.SaveEmpDto;
import com.itheima.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 * 员工表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-07-28
 */
@RestController
@RequestMapping("/emps")
public class EmpController {
    @Autowired
    private EmpService empService;
    @GetMapping
    public R queryPage(  EmpDto empDto){

       // EmpDto empDto = new EmpDto(name, gender, begin, end, page, pageSize);
        System.out.println("参数"+empDto);
        return R.ok(empService.queryPage(empDto));
    }
    @PostMapping
    public R save(@RequestBody SaveEmpDto empDto){
        System.out.println("参数"+empDto);
        empService.save(empDto);
        return R.ok();
    }
    @DeleteMapping
    public R delete(@RequestParam("ids") List<Integer> ids){
        empService.deleteBatch(ids);
        return R.ok();
    }
    @GetMapping("{id}")
    public R queryById(@PathVariable("id") Integer id){
        return R.ok(empService.queryById(id));
    }
    @GetMapping("list")
    public R list(){
        return R.ok(empService.list());
    }
    @PutMapping("changePassword")
    public R changePassword(@RequestBody ChangeUserDto changeUserDto){
        empService.changePassword(changeUserDto);
        return R.ok();
    }


}
